<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" id="form" action="{{urlfor "admin.MessageController.List"}}" method="get">
                        {{/*<div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="开始日" value="{{if .Start}}{{.Start}}{{end}}" name="start" id="start"></div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="截止日" value="{{if .End}}{{.End}}{{end}}"  name="end" id="end"></div>
                        */}}
                        <div class="layui-input-inline layui-show-xs-block">
                            <select name="status">
                                <option value="">文章状态</option>
                                <option {{if eq 1 .Status}}selected{{end}} value="1">可用</option>
                                <option {{if eq 2 .Status}}selected{{end}} value="2">禁止</option>
                            </select>
                        </div>
                        {{/*<div class="layui-input-inline layui-show-xs-block">
                            <input value="{{if .Title}}{{.Title}}{{end}}" type="text" name="title" placeholder="请输入标题" autocomplete="off" class="layui-input"></div>
                        */}}
                        <div class="layui-input-inline layui-show-xs-block">
                            <button type="reset" class="layui-btn" onclick="reset_form()"><i class="layui-icon layui-icon-refresh"></i></button>
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    {{/*<button class="layui-btn" onclick="xadmin.open('添加文章','{{urlfor "admin.ArticleController.Add"}}','','',true)">
                        <i class="layui-icon"></i>添加</button>*/}}
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>姓名</th>
                            <th>留言内容</th>
                            <th>留言时间</th>
                            <th>回复</th>
                            <th>回复时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {{range $key, $value := $.Data}}
                            <tr>
                                <td>{{IndexForOne $key $.Paginator.CurrentPage $.Paginator.PageSize}}</td>
                                <td><a  href="{{$value.Site}}}}" target="_blank">{{$value.Name}}</a></td>
                                <td>{{$value.Review}}</td>
                                <td>{{$value.Created}}</td>
                                <td>{{$value.Reply}}</td>
                                <td>{{$value.Updated}}</td>
                                <td>{{index $.StatusText $value.Status}}</td>
                                <td class="td-manage">
                                    <a title="查看" onclick="xadmin.open('编辑','{{urlfor "admin.MessageController.Put"}}?id={{$value.Id}}','800','600')" href="javascript:;">
                                        <i class="layui-icon">&#xe63c;</i></a>
                                    <a title="删除" onclick="member_del(this,'{{$value.Id}}')" href="javascript:;">
                                        <i class="layui-icon">&#xe640;</i></a>
                                </td>
                            </tr>
                        {{end}}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page" id="page">
                        <div>
                            <span class="current">{{.Paginator.CurrentPage}}</span>
                            {{if gt .Paginator.CurrentPage 1}}
                                <a class="prev" href="{{urlfor "admin.MessageController.List"}}?page={{IndexDecrOne $.Paginator.CurrentPage}}&status={{if .Status}}{{.Status}}{{end}}">上一页</a>
                            {{end}}
                            {{if lt .Paginator.CurrentPage .Paginator.TotalPage}}
                                <a class="next" href="{{urlfor "admin.MessageController.List"}}?page={{IndexAddOne $.Paginator.CurrentPage}}&status={{if .Status}}{{.Status}}{{end}}">下一页</a>
                            {{end}}
                            <span class="num">总 {{.Paginator.TotalPage}} 页</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate', 'form','laypage'],
        function() {
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
                ,format:'yyyy-MM-dd HH:mm:ss'
            });
            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
                ,format:'yyyy-MM-dd HH:mm:ss'
            });
        }
    );

    function reset_form() {
        $("#form").find('input,select,input[type=hidden]').each(function() {
            console.log($(this).val());
            console.log($(this));
            $(this).val('123');
        });
    }


    function member_del(obj, id) {
        layer.confirm('确认要下架吗？',
            function(index) {
                $.ajax({
                    url:'/admin/message/delete',
                    type:'post',
                    data:'id='+id,
                    success:function (data) {
                        //发异步删除数据
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {
                            icon: 1,
                            time: 1000
                        });
                        window.location.reload();

                    }
                });
            });
    }
</script>

</html>